package br.mywallet.view;

import java.util.List;
import com.mywallet.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter {

	private List<? extends ItemListView> itens;
	private LayoutInflater layoutList;

	public ListViewAdapter() {

	}

	public ListViewAdapter(Context ctx, List<? extends ItemListView> itens) {
		this.itens = itens;

		layoutList = LayoutInflater.from(ctx);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return itens.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return itens.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (itens != null) {
			ItemListView item = itens.get(position);

			view = layoutList.inflate(R.layout.item_list_view, null);

			((TextView) view.findViewById(R.id.itemListViewNivel1))
					.setText(item.getNivel1());
			((TextView) view.findViewById(R.id.itemListViewNivel2))
					.setText(item.getNivel2());
		}
		return view;
	}
}
